package cn.bone.springDemo.test02.service;

import cn.bone.springDemo.test02.bean.User;
import cn.bone.springDemo.test02.dao.UserDao;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by superbone on 2018/9/4.
 */
@Service
public class UserService {

    @Resource
    UserDao userDao;

    @Transactional
    public void insertUser(){
        userDao.insert();
        System.out.println("插入完成...");

        int i = 10/0;
    }

    @Transactional(readOnly = true)
    public void getUser(){
        User user = userDao.get(1);
        System.out.println(JSON.toJSONString(user));
        User u2 = userDao.get(1);
        System.out.println(JSON.toJSONString(u2));

    }
}
